package sk.avicularia.core.data;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Generated;

import sk.avicularia.core.dao.AddressDAO;
import sk.avicularia.core.dao.PersonDAO;

/**
 * Entita mapujuca strukturu person
 * 
 * @author leaflock
 * @since  0.1
 */
@Entity
@Table(name = PersonDAO.TABLE_NAME)
public class Person implements Serializable
{
	/**
	 * @see Serializable
	 */
	private static final long	serialVersionUID	= 529963600523311670L;

	/**
	 * Id zaznamu
	 */
	@Id	
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID", nullable = false)
	private Long id;
	
	/**
	 * Nick persony  
	 */
	@Column(name = PersonDAO.COLUMN_NICK, length = 50, nullable = false, unique = true)
	private String nick;
		
	/**
	 * Password persony
	 */
	@Column(name = PersonDAO.COLUMN_PASSWORD, length = 255, nullable = false)
	private String password;
	
	/**
	 * Adresa persony
	 */
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = PersonDAO.COLUMN_ID_ADDRESS, referencedColumnName = "ID", table = AddressDAO.TABLE_NAME)
	private Address address;

	public Long getId()
	{
		return id;
	}

	public void setId(Long id)
	{
		this.id = id;
	}

	public String getNick()
	{
		return nick;
	}

	public void setNick(String nick)
	{
		this.nick = nick;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password)
	{
		this.password = password;
	}

	public Address getAddress()
	{
		return address;
	}

	public void setAddress(Address address)
	{
		this.address = address;
	}
}
